import { useState } from "react";
import { Radio, Row, Col } from "antd";
import Style from "./index.module.less";
export default ({ readonly, onChange, value, options, ...props }) => {
	const handleChange = ({ target: { value } }) => {
		if (readonly) return;
		onChange && onChange(value);
	};

	if (!Array.isArray(options)) {
		return <>BtnGroup缺少options参数</>;
	}
	return (
		<Radio.Group
			value={value}
			onChange={handleChange}
			style={{ minWidth: "100%" }}
			className={Style.search_form_btn_group}
			{...props}
		>
			{options.map(item => {
				return (
					<Radio.Button
						key={item.value}
						value={item.value}
						className={value === item.value ? Style.search_form_btn_group_item_checked : Style.search_form_btn_group_item}
					>
						<span className={Style.search_form_btn_group_span}>
							{item.icon}
							<a className={Style.label}>{item.label}</a>
						</span>
					</Radio.Button>
				);
			})}
		</Radio.Group>
	);
};
